package com.ruoyi.deeplearn.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.deeplearn.domain.DeepDataType;
import com.ruoyi.deeplearn.service.IDeepDataTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 数据类型Controller
 *
 * @author rww
 * @date 2023-09-14
 */
@Deprecated
@RestController
@RequestMapping("/deeplearn/dataType")
public class DeepDataTypeController extends BaseController
{
    @Autowired
    private IDeepDataTypeService deepDataTypeService;

    /**
     * 查询数据类型列表
     */
//    @PreAuthorize("@ss.hasPermi('dataType:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeepDataType deepDataType)
    {
        startPage();
        List<DeepDataType> list = deepDataTypeService.selectDeepDataTypeList(deepDataType);
        return getDataTable(list);
    }

    @GetMapping("/list/all")
    public AjaxResult listAll(DeepDataType deepDataType)
    {
        List<DeepDataType> list = deepDataTypeService.selectDeepDataTypeList(deepDataType);
        return success(list);
    }

    /**
     * 导出数据类型列表
     */
//    @PreAuthorize("@ss.hasPermi('dataType:type:export')")
    @Log(title = "数据类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeepDataType deepDataType)
    {
        List<DeepDataType> list = deepDataTypeService.selectDeepDataTypeList(deepDataType);
        ExcelUtil<DeepDataType> util = new ExcelUtil<DeepDataType>(DeepDataType.class);
        util.exportExcel(response, list, "数据类型数据");
    }

    /**
     * 获取数据类型详细信息
     */
//    @PreAuthorize("@ss.hasPermi('dataType:type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(deepDataTypeService.selectDeepDataTypeById(id));
    }

    /**
     * 新增数据类型
     */
//    @PreAuthorize("@ss.hasPermi('dataType:type:add')")
    @Log(title = "数据类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeepDataType deepDataType)
    {
        return toAjax(deepDataTypeService.insertDeepDataType(deepDataType));
    }

    /**
     * 修改数据类型
     */
//    @PreAuthorize("@ss.hasPermi('dataType:type:edit')")
    @Log(title = "数据类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeepDataType deepDataType)
    {
        return toAjax(deepDataTypeService.updateDeepDataType(deepDataType));
    }

    /**
     * 删除数据类型
     */
//    @PreAuthorize("@ss.hasPermi('dataType:type:remove')")
    @Log(title = "数据类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(deepDataTypeService.deleteDeepDataTypeByIds(ids));
    }
}
